package java8.lamb;

/**
 * Created by fangjicai on 2020/6/6.
 */
public class ConverterTest {
    public static void main(String[] args) {
//        Converter<String,Integer> converter=(from)->Integer.parseInt(from);
//        Integer con = converter.converter("123");
//        System.out.println(con);
            //引用静态方法
//        Converter<String,Integer> converter=Integer::valueOf;
//        Integer con=converter.converter("123");
//        System.out.println(con);
            //引用对象方法
//        Person person = new Person();
//        Converter<String,Integer> con=person::parse;
//        System.out.println(con.converter("123"));
            //调用对象构造器
//        PersonFactory<Person> personPersonFactory=Person::new;
//        Person person = personPersonFactory.create("perter", "parker");
//        System.out.println(person.firstName+person.lastName);
            //访问局部变量
//        final int num=1;
//        Converter<Integer,String> stringConverter=(from)->String.valueOf(from+num);
//        String value = stringConverter.converter(2);
//        System.out.println(value);//3
         int num=1;
        Converter<Integer,String> stringConverter=(from)->String.valueOf(from+num);
        String value = stringConverter.converter(2);
        System.out.println(value);//3
    }

}
